Skip to content

fix(subturn): inherit runtime tool registry for spawned subagents#2020

Open
Alix-007 wants to merge 2 commits intosipeed:mainfrom
Alix-007:fix/issue-1713-subturn-tools-v2
Open

fix(subturn): inherit runtime tool registry for spawned subagents#2020
Alix-007 wants to merge 2 commits intosipeed:mainfrom
Alix-007:fix/issue-1713-subturn-tools-v2

Conversation

@Alix-007
Copy link
Copy Markdown
Contributor

Summary

Fixes #1713.

This PR keeps spawned/subagent child turns aligned with the parent turn's runtime tool registry, instead of pre-snapshotting tools into SubTurnConfig.Tools.

  • spawn / subagent now leave SubTurnConfig.Tools unset (nil) so child turns inherit at execution time from the parent turn context.
  • spawnSubTurn now prioritizes cloning baseAgent.Tools when available, preserving registry semantics (including hidden tools and TTL gating).
  • Explicit cfg.Tools is only used as a fallback when the parent registry is unavailable and the explicit slice is non-empty.
  • Empty explicit tool slices no longer clear inherited tools.

Why

The bug report describes spawned subagents missing tool definitions in provider requests. The robust fix is to inherit from the live parent registry so child turns receive the same tool visibility and runtime additions as the parent, while keeping hidden/TTL behavior intact.

Validation

Focused tests were added/updated to assert provider-level tool definitions and edge cases:

  • TestSpawnSubTurn_EmptyExplicitToolsStillInheritParentRegistry
  • TestSpawnSubTurn_InheritsRuntimeAddedTools
  • TestSpawnSubTurn_PreservesHiddenTTLSemantics
  • TestSpawnSubTurn_UsesExplicitToolsWhenParentRegistryUnavailable
  • TestSpawnTool_Execute_LeavesToolsUnsetForRuntimeInheritance
  • TestSubagentTool_Execute_LeavesToolsUnsetForRuntimeInheritance

Commands run:

  • go test ./pkg/tools -run 'TestSpawnTool_Execute_(ValidTask|LeavesToolsUnsetForRuntimeInheritance)|TestSubagentTool_Execute_(Success|LeavesToolsUnsetForRuntimeInheritance)' -count=1\n- go test ./pkg/agent -run 'TestSpawnSubTurn_(EmptyExplicitToolsStillInheritParentRegistry|InheritsRuntimeAddedTools|PreservesHiddenTTLSemantics|UsesExplicitToolsWhenParentRegistryUnavailable)' -count=1\n- go test ./pkg/tools -run 'TestSpawnTool_|TestSubagentTool_' -count=1\n- go test ./pkg/agent -run 'TestSpawnSubTurn_' -count=1

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: agent domain: tool go Pull requests that update go code labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: agent domain: tool go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Subagents spawned via spawn tool have no tools

1 participant